﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace InstallManager.Msi
{
    public class MsiActionMessage
    {
        public string Time { get; private set; }
        public string Action { get; private set; }
        public string Description { get; private set; }
       

        public MsiActionMessage(string message)
        {
            if (!string.IsNullOrEmpty(message))
            {
                Regex regex = new Regex("(?<time>[\\d:]+): (?<action>[\\w]+)\\. (?<description>[\\w\\d\\s]+)*");
                if (regex.IsMatch(message))
                {
                    Match match = regex.Match(message);
                    Time = match.Groups["time"].Value;
                    Action = match.Groups["action"].Value;
                    Description = match.Groups["description"].Value;
                }
            }
        }

        public override string ToString()
        {
            return String.Format("Time:{0} Action:{1} Description:{2}", Time, Action, Description);
        }
    }
}
